//
//  SSMainNavigationController.m
//  电商项目
//
//  Created by Esther on 2017/2/18.
//  Copyright © 2017年 Esther. All rights reserved.
//

#import "SSMainNavigationController.h"

@interface SSMainNavigationController ()

@end

@implementation SSMainNavigationController
// 保证属性只设置一次
+ (void)initialize{
    
    
    UINavigationBar *navBar = [UINavigationBar appearance];
    
    [navBar setBackgroundImage:[UIImage imageNamed:@"nav_backImage"] forBarMetrics:UIBarMetricsDefault];
    NSDictionary *dict = @{NSForegroundColorAttributeName : [UIColor blackColor],
                           NSFontAttributeName : [UIFont systemFontOfSize:20.0]};
    [navBar setTitleTextAttributes:dict];
    // 透明度
    navBar.alpha = 1.0;
    navBar.translucent = NO;
    
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    if (self.childViewControllers.count) {
        UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [backButton setBackgroundImage:[UIImage imageNamed:@"详情界面返回按钮"] forState:(UIControlStateNormal)];
        backButton.frame = CGRectMake(0, 0, 30, 30);
        [backButton addTarget:self action:@selector(returnViewController) forControlEvents:(UIControlEventTouchUpInside)];
        
        UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:backButton];
        viewController.navigationItem.leftBarButtonItem = item;
        viewController.hidesBottomBarWhenPushed = YES;
        
    }
    [super pushViewController:viewController animated:animated];
    
}

- (void)returnViewController{
    [self popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
